<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/19
  Time: 16:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <style>
        tr td {
            text-align: center;
        }
    </style>
</head>
<body>
<jsp:include page="top.jsp"></jsp:include>
<div style="width: 70%;height: 50px;position: relative;margin: 30px auto">
    <a href="add.jsp" style="position: absolute;right: 0px;top: 0px;">添加学生</a>
</div>
<center>
    <form action="">
        姓名<input type="text" name="name" size="8"/>
        性别
        <select name="sex">
            <option value="0">男</option>
            <option value="1">女</option>
        </select>
        <input type="submit" value="查询"/>
        <input type="hidden" name="id" value="${s.sid}">
    </form>
</center>
<table border="1px" align="center" width="70%" height="500px" cellpadding="0" cellspacing="0">
    <caption>学生信息展示</caption>
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>年龄</th>
        <th>生日</th>
        <th>邮箱</th>
        <th>性别</th>
        <th>操作</th>
        <th>头像</th>
    </tr>
    <!--遍历list集合-->
    <c:forEach items="${list}" var="s">
        <tr>
            <td>${s.sid}</td>
            <td>${s.sname}</td>
            <td>${s.age}</td>
            <td>${s.sbir}</td>
            <td>${s.email}</td>
            <td>
                <c:if test="${s.sex==0}">男</c:if>
                <c:if test="${s.sex==1}">女</c:if>
            </td>
            <td>
                <a href="delete?id=${s.sid}">删除</a>&nbsp;&nbsp;&nbsp;<a href="upStu?id=${s.sid}">修改</a></td>
            <td>
                <img src="/pic/${s.spic}" height="99px">
            </td>
            <td></td>
        </tr>
    </c:forEach>
</table>
<center>
    <a href="queryStuByPage?curPage=1">首页</a>
    <a href="queryStuByPage?curPage=${pu.prevPage}">上一页</a>
    <c:forEach begin="1" end="${pu.endPage}" var="n">
        <a href="queryStuByPage?curPage=${n}">${n}</a> &nbsp;&nbsp;&nbsp;
    </c:forEach>
    <a href="queryStuByPage?curPage=${pu.nextPage}">下一页</a>
    <a href="queryStuByPage?curPage=${pu.endPage}">尾页</a>
    <span>${pu.curPage}/${pu.endPage}</span>
    <span>总记录数:${pu.rows}</span>
    <input size="3" id="pageNum"/>
    <input type="button" value="跳转" onclick="jumpPage(${pu.endPage})"/>
</center>
</body>
<script>
    function jumpPage(n){
        //获取跳转页码
        var num = document.getElementById("pageNum").value;
        if(num>=1&&num<=n){
            //发送分页请求
            location.href="queryStuByPage?curPage="+num;
        }else{
            alert("请输入有效页码")
        }
    }
</script>
</html>
